package com.xxgc.dao;

import com.xxgc.pojos.Category;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CategoryDaoImpl implements CategoryDaoI{

    BaseDao bdao=new BaseDao();
    @Override
    public List<Category> queryAll() {
        List<Category> list=new ArrayList<Category>();
        String sql="select * from category";
        ResultSet rs=bdao.query(sql);
        try {
            while (rs.next()) {
                Category c = new Category();
                c.setCid(rs.getLong(1));
                c.setCname(rs.getString(2));
                c.setPid(rs.getLong(3));
                list.add(c);
            }
            bdao.close();
            }catch (SQLException throwables) {
                throwables.printStackTrace();
        }
        return list;
    }
}
